<include file="public@header" />
</head>
<script type="text/html" id="exteriors-item-tpl">
    <li id="saved-image{id}">
        <input id="excerpt-{id}" type="hidden" name="excerpt_urls[]" value="{filepath}">
        <input class="form-control" id="excerpt-{id}-name" type="text" name="excerpt_names[]" value="{name}" style="width: 200px;" title="图片名称">
        <img id="excerpt-{id}-preview" src="{url}" style="height:36px;width: 36px;" onclick="imagePreviewDialog(this.src);">
        <a href="javascript:uploadOneImage('图片上传','#excerpt-{id}');">替换</a>
        <a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>
    </li>
</script>
<script type="text/html" id="interiors-item-tpl">
    <li id="saved-image{id}">
        <input id="interior-{id}" type="hidden" name="interior_urls[]" value="{filepath}">
        <input class="form-control" id="interior-{id}-name" type="text" name="interior_names[]" value="{name}" style="width: 200px;" title="图片名称">
        <img id="interior-{id}-preview" src="{url}" style="height:36px;width: 36px;" onclick="imagePreviewDialog(this.src);">
        <a href="javascript:uploadOneImage('图片上传','#interior-{id}');">替换</a>
        <a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>
    </li>
</script>

<style>
    .input-group-addon {
        font-weight: bold;
        background-color: #3498db;
        color: white;
        border: 0px;
    }
</style>

<body>
    <div class="wrap js-check-wrap">
        <ul class="nav nav-tabs">
            <li><a href="{:url('AdminCar/index')}">汽车管理</a></li>
            <li><a href="{:url('AdminCar/add')}">添加汽车</a></li>
            <li class="active"><a href="#">编辑汽车</a></li>
        </ul>
        <div class="row margin-top-20">
            <div class="col-md-2">
                <div class="list-group">
                    <a class="list-group-item" href="#A" data-toggle="tab">基本属性</a>
                    <a class="list-group-item" href="#B" data-toggle="tab">车身属性</a>
                    <a class="list-group-item" href="#C" data-toggle="tab">发动机属性</a>
                    <a class="list-group-item" href="#D" data-toggle="tab">驱动属性</a>
                    <a class="list-group-item" href="#E" data-toggle="tab">底盘属性</a>
                    <a class="list-group-item" href="#F" data-toggle="tab">汽车图片</a>
                    <a class="list-group-item" href="#G" data-toggle="tab">SEO设置</a>
                </div>
            </div>
            <div class="col-md-6">
                <form class="js-ajax-form" action="{:url('AdminCar/editPost')}" method="post">
                    <input type="hidden" name="id" value="{$car.id}" />
                    <div class="tab-content">
                        <div class="tab-pane active" id="A">
                            <div class="form-group">
                                <label for="input-name"><span class="form-required">*</span>标题</label>
                                <div>
                                    <input type="text" class="form-control" id="input-name" name="title" value="{$car.title}">
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-md-3 col-sm-10" style="padding-left: 0px;">
                                    <select class="form-control" name="category_id">
                                    <option value="">选择分类</option>
                                    <volist name="category_tree" id="vo">
                                        <option value='{$vo.id}' {$car.category_id==$vo.id?'selected':''}>{$vo.name}</option>
                                    </volist>
                                </select>
                                </div>
                                <div class="col-md-3 col-sm-10 " style="padding-left: 0px;">
                                    <select class="form-control" name="brand_id">
                                    <option value="">选择品牌</option>
                                     <volist name="brands" id="vo">
                                        <option value='{$vo.id}' {$car.brand_id==$vo.id?'selected':''}>{$vo.name}</option>
                                    </volist>
                                </select>
                                </div>
                                <div class="col-md-3 col-sm-10 " style="padding: 0px;">
                                    <select class="form-control" name="rank_id">
                                    <option value="">选择级别</option>
                                    <volist name="ranks" id="vo">
                                        <option value='{$vo.id}' {$car.rank_id==$vo.id?'selected':''}>{$vo.rank}</option>
                                    </volist>
                                    </select>
                                </div>
                                <div class="col-md-3 col-sm-10 " style="padding: 0px;">
                                    <select class="form-control" name="year_id">
                                    <option value="0">新车</option>
                                    <volist name="years" id="vo">
                                        <option value='{$vo.id}'  {$car.year_id==$vo.id?'selected':''}>{$vo.year}</option>
                                    </volist>
                                    </select>
                                </div>
                                <div style="clear:both"></div>
                            </div>
                            <div class="form-group">
                                <label for="input-name"><span class="form-required">*</span>品牌型号</label>
                                <div>
                                    <input type="text" class="form-control" id="input-name" name="car_model" value="{$car.car_model|default=''}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="input-excerpt">缩略图</label>
                                <div>
                                    <input type="hidden" name="more[thumbnail]" id="thumbnail" value="{$car.more.thumbnail|default=''}">
                                    <a href="javascript:uploadOneImage('图片上传','#thumbnail');">
                                        <if condition="empty($car.more.thumbnail)">
                                            <img src="__TMPL__/public/assets/images/default-thumbnail.png" id="thumbnail-preview" width="135" style="cursor: pointer" />
                                            <else/>
                                            <img src="{:cmf_get_image_preview_url($car.more.thumbnail)}" id="thumbnail-preview" width="135" style="cursor: pointer" />
                                        </if>
                                    </a>
                                    <input type="button" class="btn btn-sm btn-cancel-thumbnail" value="取消图片">
                                </div>
                            </div>
                            <div class="col-md-6 col-sm-10" style="padding: 0px;">
                                <div class="form-group">
                                    <label for="input-name">价格</label>
                                    <div class="input-group">
                                        <input type="text" class="form-control" name="primary[price]" value="{$car.primary.price|default='180'}">
                                        <span class="input-group-addon">万</span>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="input-name">市场价</label>
                                    <div class="input-group">
                                        <input type="text" class="form-control" name="primary[m_price]" value="{$car.primary.m_price|default=''}">
                                        <span class="input-group-addon">万</span>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="input-name">类型</label>
                                    <div>
                                        <input type="text" class="form-control" name="primary[type]" value="{$car.primary.type|default='欧规 现车'}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="input-name">外观</label>
                                    <div>
                                        <input type="text" class="form-control" name="primary[exterior]" value="{$car.primary.exterior|default='黑色'}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="input-name">内饰</label>
                                    <div>
                                        <input type="text" class="form-control" name="primary[interior]" value="{$car.primary.interior|default='灰色'}">
                                    </div>
                                </div>
                            </div>
                            <div style="clear:both"></div>
                            <div class="form-group ">
                                <label for="input-post_excerpt ">车型配置内容</label>
                                <div>
                                    <textarea class="form-control " name="post_content" id="input-post_content">{$car.post_content|default=''}</textarea>
                                </div>
                            </div>
                        </div>
                        <div class="tab-pane" id="B">
                            <div class="col-md-6 col-sm-10" style="padding: 0px;">
                                <div class=" form-group ">
                                    <label for="input-post_keywords ">尺寸</label>
                                    <div style="clear:both"></div>

                                    <div class="input-group" style="margin-top: 10px;">
                                        <input class="form-control" placeholder="车身长度" name="bodywork[length]" type="text" value="{$car.bodywork.length|default='4850'}">
                                        <span class="input-group-addon">毫米</span>
                                    </div>
                                    <div class="input-group" style="margin-top: 10px;">
                                        <input class="form-control" placeholder="车身宽度" name="bodywork[width]" type="text" value="{$car.bodywork.width|default='2073'}">
                                        <span class="input-group-addon">毫米</span>
                                    </div>
                                    <div class="input-group" style="margin-top: 10px;">
                                        <input class="form-control" placeholder="车身高度" name="bodywork[height]" type="text" value="{$car.bodywork.height|default='1780'}">
                                        <span class="input-group-addon">毫米</span>
                                    </div>
                                </div>
                                <div class="form-group ">
                                    <label for="input-post_keywords ">车身结构</label>
                                    <div>
                                        <input type="text " class="form-control " id="input-bodywork-structure " name="bodywork[structure] " value="{$car.bodywork.structure|default='5门5座 SUV' } ">
                                    </div>
                                </div>
                                <div class="form-group ">
                                    <label for="input-post_excerpt">轴距</label>
                                    <div>
                                        <div class="input-group" style="margin-top: 10px;">
                                            <input class="form-control" placeholder="车身轴距" name="bodywork[wheel_base]" type="text" value="{$car.bodywork.wheel_base|default='2923'}">
                                            <span class="input-group-addon">毫米</span>
                                        </div>

                                    </div>
                                </div>
                            </div>
                            <div style="clear:both"></div>
                        </div>
                        <div class="tab-pane" id="C">
                            <div class="form-group">
                                <div class="col-md-4 col-sm-10" style="padding-left: 0px;">
                                    <select class="form-control" name="emission_id">
                                    <option value="">选择排量</option>
                                    <volist name="emissions" id="vo">
                                        <option value='{$vo.id}' {$car.emission_id==$vo.id?'selected':''}>{$vo.emission}</option>
                                    </volist>
                                </select>
                                </div>
                                <div style="clear:both"></div>
                            </div>
                            <div class=" form-group ">
                                <label for="input-post_title ">发动机型号</label>
                                <div>
                                    <input type="text" class="form-control" name="engine[type]" value="{$car.engine.type|default='2.9T 446马力 V6'}">
                                </div>
                            </div>
                            <div class="form-group ">
                                <label for="input-post_keywords ">最大扭矩</label>
                                <div>
                                    <input type="text" class="form-control" name="engine[max_torque]" value="{$car.engine.max_torque|default='549N`m@1750-5500'}">
                                </div>
                            </div>
                            <div class="form-group ">
                                <label for="input-post_keywords ">最大马力</label>
                                <div>
                                    <input type="text" class="form-control" name="engine[max_horsepower]" value="{$car.engine.max_horsepower|default='446Ps@5650-6600'}">
                                </div>
                            </div>
                            <div class="form-group ">
                                <label for="input-post_keywords ">燃料类型</label>
                                <div>
                                    <input type="text" class="form-control" name="engine[fuel]" value="{$car.engine.fuel|default='汽油'}">
                                </div>
                            </div>
                        </div>
                        <div class="tab-pane" id="D">
                            <div class=" form-group ">
                                <label for="input-post_title ">变速箱</label>
                                <div>
                                    <input type="text" class="form-control" name="drive[gearbox]" value="{$car.drive.gearbox|default='8挡双离合器'}">
                                </div>
                            </div>
                            <div class="form-group ">
                                <label for="input-post_keywords ">驱动方式</label>
                                <div>
                                    <input type="text" class="form-control" name="drive[type]" value="{$car.drive.type|default='前置四驱'}">
                                </div>
                            </div>
                        </div>

                        <div class="tab-pane" id="E">
                            <div class=" form-group ">
                                <label for="input-post_title ">前悬架类型</label>
                                <div>
                                    <input type="text" class="form-control" name="underpan[front_suspension]" value="{$car.underpan.front_suspension|default='双叉臂独立悬架'}">
                                </div>
                            </div>
                            <div class=" form-group ">
                                <label for="input-post_title ">后悬架类型</label>
                                <div>
                                    <input type="text" class="form-control" name="underpan[rear_suspension]" value="{$car.underpan.rear_suspension|default='双叉臂独立悬架'}">
                                </div>
                            </div>
                            <div class="form-group ">
                                <label for="input-post_keywords ">车体结构</label>
                                <div>
                                    <input type="text" class="form-control" name="underpan[structure]" value="{$car.underpan.structure|default='承载式'}">
                                </div>
                            </div>

                        </div>
                        <div class="tab-pane" id="F">
                            <div class=" form-group ">
                                <label for="input-post_title ">车身图片</label>
                                <div>
                                    <ul id="exteriors" class="pic-list list-unstyled form-inline">
                                        <notempty name="car.more.excerpts">
                                            <foreach name="car.more.excerpts" item="vo">
                                                <php>$img_url=cmf_get_image_preview_url($vo['url']);</php>
                                                <li id="saved-image{$key}">
                                                    <input id="exterior-{$key}" type="hidden" name="excerpt_urls[]" value="{$vo.url}">
                                                    <input class="form-control" id="exterior-{$key}-name" type="text" name="excerpt_names[]" value="{$vo.name|default=''}" style="width: 200px;" title="图片名称">
                                                    <img id="exterior-{$key}-preview" src="{:cmf_get_image_preview_url($vo['url'])}" style="height:36px;width: 36px; padding:2px" onclick="parent.imagePreviewDialog(this.src);">
                                                    <a href="javascript:uploadOneImage('图片上传','#photo-{$key}');">替换</a>
                                                    <a href="javascript:(function(){$('#saved-image{$key}').remove();})();">移除</a>
                                                </li>
                                            </foreach>
                                        </notempty>
                                    </ul>
                                    <a href="javascript:uploadMultiImage('图片上传','#exteriors','exteriors-item-tpl');" class="btn btn-default btn-sm">选择图片</a>
                                </div>
                            </div>
                            <div class="form-group ">
                                <label for="input-post_keywords ">内饰图片</label>
                                <div>
                                    <ul id="interiors" class="pic-list list-unstyled form-inline">
                                        <notempty name="car.more.interiors">
                                            <foreach name="car.more.interiors" item="vo">
                                                <php>$img_url=cmf_get_image_preview_url($vo['url']);</php>
                                                <li id="saved-image{$key}">
                                                    <input id="exterior-{$key}" type="hidden" name="interior_urls[]" value="{$vo.url}">
                                                    <input class="form-control" id="exterior-{$key}-name" type="text" name="interior_names[]" value="{$vo.name|default=''}" style="width: 200px;" title="图片名称">
                                                    <img id="exterior-{$key}-preview" src="{:cmf_get_image_preview_url($vo['url'])}" style="height:36px;width: 36px; padding:2px" onclick="parent.imagePreviewDialog(this.src);">
                                                    <a href="javascript:uploadOneImage('图片上传','#photo-{$key}');">替换</a>
                                                    <a href="javascript:(function(){$('#saved-image{$key}').remove();})();">移除</a>
                                                </li>
                                            </foreach>
                                        </notempty>
                                    </ul>
                                    <a href="javascript:uploadMultiImage('图片上传','#interiors','interiors-item-tpl');" class="btn btn-default btn-sm">选择图片</a>
                                </div>
                            </div>
                        </div>
                        <div class="tab-pane" id="G">

                            <div class=" form-group ">
                                <label for="input-post_title ">状态</label>
                                <div>
                                    <input name="post_status" value="1" type="checkbox" checked='true'> 发布&nbsp;&nbsp;&nbsp;
                                    <input name="recommended" value="1" type="checkbox" checked='true'> 推荐
                                </div>
                            </div>
                            <div class=" form-group ">
                                <label for="input-post_title ">SEO标题</label>
                                <div>
                                    <input type="text " class="form-control " id="input-post_title" name="post_title" value="{$car.post_title|default='' } ">
                                </div>
                            </div>
                            <div class="form-group ">
                                <label for="input-post_keywords ">SEO关键字</label>
                                <div>
                                    <input type="text " class="form-control " id="input-post_keywords" name="post_keywords" value="{$car.post_keywords|default='' } ">
                                </div>
                            </div>
                            <div class="form-group ">
                                <label for="input-post_excerpt ">SEO描述</label>
                                <div>
                                    <textarea class="form-control " name="post_excerpt" id="input-post_excerpt">{$car.post_excerpt|default=''}</textarea>
                                </div>
                            </div>
                        </div>

                    </div>
                    <div class="form-group ">
                        <button type="submit" class="btn btn-success js-ajax-submit">{:lang('SAVE')}</button>
                        <a class="btn btn-default " href="{:url( 'AdminCar/index')} ">{:lang('BACK')}</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <script type="text/javascript " src="__STATIC__/js/admin.js "></script>
    <script type="text/javascript">
        $(function() {
            $('.btn-cancel-thumbnail').click(function() {
                $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
                $('#thumbnail').val('');
            });

        });
    </script>
</body>

</html>